﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using RoadTeam.Model;
using RoadTeam.Enums;
using RoadTeam.SysInterface;

namespace RoadTeam.BsSystem.CS.HomeInspection
{
    public class TbCsRoomType_Sys : ICsRoomType
    {

        public String GetRoomTypeID(String Identifier)
        {
            SqlWhere where = new SqlWhere();
            where.Info = new TbCsRoomType() { App_Identifier = Identifier };
            where.SelectColumn = @" top 1 roomtypeid  ";
            DataTable dt = TbCsRoomType.Select(where, GlobalConfig.RtConnectionString);
            if (dt.Rows.Count == 0) return @"-1";
            return dt.Rows[0][0].ToString();
        }

        public String GetCsRoomTypeIdentifier(String Roomid)
        {
            SqlWhere where = new SqlWhere();
            where.Info = new TbCsRoomType() { RoomTypeID = Convert.ToDecimal(Roomid) };
            where.SelectColumn = @" top 1 App_Identifier  ";
            DataTable dt = TbCsRoomType.Select(where, GlobalConfig.RtConnectionString);
            if (dt.Rows.Count == 0) return @"-1";
            return dt.Rows[0][0].ToString();
        }

        public DataTable GetRoomTypeData(String InID)
        {
            if (String.IsNullOrEmpty(InID))return new DataTable();
            SqlWhere where = new SqlWhere();
            where.StrSqlWhere = @"  RoomTypeID IN (" + InID + ") ";
            return TbCsRoomType.Select(where, GlobalConfig.RtConnectionString);
        }



        public DataTable GetRoomTypeTable(String organID)
        {
            SqlWhere where = new SqlWhere();
            where.Info = new TbCsRoomType() { OrganID = Convert.ToDecimal(organID) };
            where.StrSqlWhere = @" App_Identifier Is  NULL  ";
            where.SelectColumn = @" RoomTypeName,RoomTypeCode,App_Identifier,RoomTypeID ";
            return TbCsRoomType.Select(where, GlobalConfig.RtConnectionString);
        }

        public bool UpdateRoomTypeTable(DataTable dt)
        {
            return TbCsRoomType.Update(dt, GlobalConfig.RtConnectionString);
        }






    }
}
